<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>HTML篇(一)-cnblog | 凌歆的博客</title>
    <meta name="generator" content="VuePress 1.9.5">
    <link rel="icon" href="/img/favicon.ico">
    <meta name="description" content="web前端技术博客,专注web前端学习与总结。JavaScript,js,ES6,TypeScript,vue,React,python,css3,html5,Node,git,github等技术文章。">
    <meta name="keywords" content="前端博客,个人技术博客,前端,前端开发,前端框架,web前端,前端面试题,技术文档,学习,面试,JavaScript,js,ES6,TypeScript,vue,python,css3,html5,Node,git,github,markdown">
    <meta name="baidu-site-verification" content="7F55weZDDc">
    <meta name="theme-color" content="#11a8cd">
    
    <link rel="preload" href="/assets/css/0.styles.d9c8cf8c.css" as="style"><link rel="preload" href="/assets/js/app.57550e13.js" as="script"><link rel="preload" href="/assets/js/2.f014c35f.js" as="script"><link rel="preload" href="/assets/js/128.0edf0e06.js" as="script"><link rel="prefetch" href="/assets/js/10.03a98811.js"><link rel="prefetch" href="/assets/js/100.145e708e.js"><link rel="prefetch" href="/assets/js/101.098ca5c8.js"><link rel="prefetch" href="/assets/js/102.4d45c69a.js"><link rel="prefetch" href="/assets/js/103.499de505.js"><link rel="prefetch" href="/assets/js/104.c2c1b9b6.js"><link rel="prefetch" href="/assets/js/105.4e9b0663.js"><link rel="prefetch" href="/assets/js/106.9bb8cf6f.js"><link rel="prefetch" href="/assets/js/107.a81b32d7.js"><link rel="prefetch" href="/assets/js/108.81511e67.js"><link rel="prefetch" href="/assets/js/109.6a6741bf.js"><link rel="prefetch" href="/assets/js/11.e8729182.js"><link rel="prefetch" href="/assets/js/110.de657fe7.js"><link rel="prefetch" href="/assets/js/111.b092af6d.js"><link rel="prefetch" href="/assets/js/112.2dca5709.js"><link rel="prefetch" href="/assets/js/113.dbed1fac.js"><link rel="prefetch" href="/assets/js/114.e95a0131.js"><link rel="prefetch" href="/assets/js/115.2e3e8285.js"><link rel="prefetch" href="/assets/js/116.e64f7fec.js"><link rel="prefetch" href="/assets/js/117.583552c9.js"><link rel="prefetch" href="/assets/js/118.aa5d18f0.js"><link rel="prefetch" href="/assets/js/119.0c7b52d7.js"><link rel="prefetch" href="/assets/js/12.d63acec2.js"><link rel="prefetch" href="/assets/js/120.13f86281.js"><link rel="prefetch" href="/assets/js/121.e2b5b7f9.js"><link rel="prefetch" href="/assets/js/122.5252216a.js"><link rel="prefetch" href="/assets/js/123.8b8a3503.js"><link rel="prefetch" href="/assets/js/124.60df855c.js"><link rel="prefetch" href="/assets/js/125.f073ab1c.js"><link rel="prefetch" href="/assets/js/126.7b73de6a.js"><link rel="prefetch" href="/assets/js/127.4e25971c.js"><link rel="prefetch" href="/assets/js/129.5cb5a70a.js"><link rel="prefetch" href="/assets/js/13.2259ef71.js"><link rel="prefetch" href="/assets/js/130.00247fda.js"><link rel="prefetch" href="/assets/js/131.d6fc003a.js"><link rel="prefetch" href="/assets/js/132.1a32b18f.js"><link rel="prefetch" href="/assets/js/133.e46c0193.js"><link rel="prefetch" href="/assets/js/134.a6ad681f.js"><link rel="prefetch" href="/assets/js/135.2fcbe137.js"><link rel="prefetch" href="/assets/js/136.f69bf451.js"><link rel="prefetch" href="/assets/js/137.b9ef2fcc.js"><link rel="prefetch" href="/assets/js/138.7fdd9feb.js"><link rel="prefetch" href="/assets/js/139.a3a37c91.js"><link rel="prefetch" href="/assets/js/14.0d6b23b9.js"><link rel="prefetch" href="/assets/js/140.a7c013ae.js"><link rel="prefetch" href="/assets/js/141.956c36ce.js"><link rel="prefetch" href="/assets/js/142.5aacfe42.js"><link rel="prefetch" href="/assets/js/143.57d691ef.js"><link rel="prefetch" href="/assets/js/144.b1e5766e.js"><link rel="prefetch" href="/assets/js/145.463284b7.js"><link rel="prefetch" href="/assets/js/146.6cc6420c.js"><link rel="prefetch" href="/assets/js/147.5b78c5a2.js"><link rel="prefetch" href="/assets/js/148.8d1d7679.js"><link rel="prefetch" href="/assets/js/149.4e0eb213.js"><link rel="prefetch" href="/assets/js/15.f6fde69d.js"><link rel="prefetch" href="/assets/js/150.b183de37.js"><link rel="prefetch" href="/assets/js/151.729ae770.js"><link rel="prefetch" href="/assets/js/152.b1297018.js"><link rel="prefetch" href="/assets/js/153.bb991bca.js"><link rel="prefetch" href="/assets/js/154.6f2286aa.js"><link rel="prefetch" href="/assets/js/155.6a9c7e4d.js"><link rel="prefetch" href="/assets/js/156.f7bd535d.js"><link rel="prefetch" href="/assets/js/157.64c0065c.js"><link rel="prefetch" href="/assets/js/158.d31ae949.js"><link rel="prefetch" href="/assets/js/159.7daea8a7.js"><link rel="prefetch" href="/assets/js/16.7be21beb.js"><link rel="prefetch" href="/assets/js/160.33cc971a.js"><link rel="prefetch" href="/assets/js/161.1676442a.js"><link rel="prefetch" href="/assets/js/162.71378046.js"><link rel="prefetch" href="/assets/js/163.99e49959.js"><link rel="prefetch" href="/assets/js/164.306f07d2.js"><link rel="prefetch" href="/assets/js/165.170977c7.js"><link rel="prefetch" href="/assets/js/166.f8602525.js"><link rel="prefetch" href="/assets/js/167.eea5c001.js"><link rel="prefetch" href="/assets/js/168.0146a311.js"><link rel="prefetch" href="/assets/js/169.05f9c9d9.js"><link rel="prefetch" href="/assets/js/17.2543f471.js"><link rel="prefetch" href="/assets/js/170.25d602b2.js"><link rel="prefetch" href="/assets/js/171.1ada26a6.js"><link rel="prefetch" href="/assets/js/172.2a0f697c.js"><link rel="prefetch" href="/assets/js/173.230d8ca8.js"><link rel="prefetch" href="/assets/js/174.e3758a2b.js"><link rel="prefetch" href="/assets/js/175.0f19f8ea.js"><link rel="prefetch" href="/assets/js/176.bf70d37d.js"><link rel="prefetch" href="/assets/js/177.4400f272.js"><link rel="prefetch" href="/assets/js/178.85af7b89.js"><link rel="prefetch" href="/assets/js/179.4cfaaaa2.js"><link rel="prefetch" href="/assets/js/18.394415f8.js"><link rel="prefetch" href="/assets/js/180.449c8409.js"><link rel="prefetch" href="/assets/js/181.73276924.js"><link rel="prefetch" href="/assets/js/182.5fab25cc.js"><link rel="prefetch" href="/assets/js/183.ecd4934d.js"><link rel="prefetch" href="/assets/js/184.246092cf.js"><link rel="prefetch" href="/assets/js/185.c671cd86.js"><link rel="prefetch" href="/assets/js/186.49bd1963.js"><link rel="prefetch" href="/assets/js/187.1fb32764.js"><link rel="prefetch" href="/assets/js/188.7c6885e9.js"><link rel="prefetch" href="/assets/js/189.a8701dec.js"><link rel="prefetch" href="/assets/js/19.ca7db8ea.js"><link rel="prefetch" href="/assets/js/190.ae3d3bde.js"><link rel="prefetch" href="/assets/js/191.ad7cd44e.js"><link rel="prefetch" href="/assets/js/192.bc443842.js"><link rel="prefetch" href="/assets/js/193.e4755764.js"><link rel="prefetch" href="/assets/js/194.814112ce.js"><link rel="prefetch" href="/assets/js/195.1c0aaa80.js"><link rel="prefetch" href="/assets/js/196.a6bd7add.js"><link rel="prefetch" href="/assets/js/20.4e91cd31.js"><link rel="prefetch" href="/assets/js/21.f095e6e1.js"><link rel="prefetch" href="/assets/js/22.72f4b8ab.js"><link rel="prefetch" href="/assets/js/23.e94eb9d2.js"><link rel="prefetch" href="/assets/js/24.0eae7d6f.js"><link rel="prefetch" href="/assets/js/25.36157609.js"><link rel="prefetch" href="/assets/js/26.dc5b6cba.js"><link rel="prefetch" href="/assets/js/27.c19b7b63.js"><link rel="prefetch" href="/assets/js/28.3aceae59.js"><link rel="prefetch" href="/assets/js/29.536091b3.js"><link rel="prefetch" href="/assets/js/3.d11119c4.js"><link rel="prefetch" href="/assets/js/30.821a4a30.js"><link rel="prefetch" href="/assets/js/31.5238784c.js"><link rel="prefetch" href="/assets/js/32.10bc7179.js"><link rel="prefetch" href="/assets/js/33.c1ed69c9.js"><link rel="prefetch" href="/assets/js/34.8d384231.js"><link rel="prefetch" href="/assets/js/35.d8890e52.js"><link rel="prefetch" href="/assets/js/36.eca37ad5.js"><link rel="prefetch" href="/assets/js/37.802549e3.js"><link rel="prefetch" href="/assets/js/38.53841770.js"><link rel="prefetch" href="/assets/js/39.7ae44409.js"><link rel="prefetch" href="/assets/js/4.493b9bca.js"><link rel="prefetch" href="/assets/js/40.ce56364a.js"><link rel="prefetch" href="/assets/js/41.85f0114b.js"><link rel="prefetch" href="/assets/js/42.714da6e2.js"><link rel="prefetch" href="/assets/js/43.fee4437c.js"><link rel="prefetch" href="/assets/js/44.b039b68b.js"><link rel="prefetch" href="/assets/js/45.96a55605.js"><link rel="prefetch" href="/assets/js/46.956ffb03.js"><link rel="prefetch" href="/assets/js/47.147d9218.js"><link rel="prefetch" href="/assets/js/48.ff787b40.js"><link rel="prefetch" href="/assets/js/49.871eee87.js"><link rel="prefetch" href="/assets/js/5.e0ba07d7.js"><link rel="prefetch" href="/assets/js/50.99b7c29e.js"><link rel="prefetch" href="/assets/js/51.8ecbf4ba.js"><link rel="prefetch" href="/assets/js/52.53d91d7e.js"><link rel="prefetch" href="/assets/js/53.af8a0d2a.js"><link rel="prefetch" href="/assets/js/54.a2f848b5.js"><link rel="prefetch" href="/assets/js/55.267e9947.js"><link rel="prefetch" href="/assets/js/56.0b201c40.js"><link rel="prefetch" href="/assets/js/57.cbdfd6f7.js"><link rel="prefetch" href="/assets/js/58.636c0c3f.js"><link rel="prefetch" href="/assets/js/59.fc9216c4.js"><link rel="prefetch" href="/assets/js/6.b98373f2.js"><link rel="prefetch" href="/assets/js/60.34f16fc4.js"><link rel="prefetch" href="/assets/js/61.4d130bd8.js"><link rel="prefetch" href="/assets/js/62.927caa10.js"><link rel="prefetch" href="/assets/js/63.a451fee0.js"><link rel="prefetch" href="/assets/js/64.32a5d47b.js"><link rel="prefetch" href="/assets/js/65.bc099429.js"><link rel="prefetch" href="/assets/js/66.3953050d.js"><link rel="prefetch" href="/assets/js/67.e934823b.js"><link rel="prefetch" href="/assets/js/68.4bcb52b0.js"><link rel="prefetch" href="/assets/js/69.bede18c8.js"><link rel="prefetch" href="/assets/js/7.8de8df2d.js"><link rel="prefetch" href="/assets/js/70.fce1daac.js"><link rel="prefetch" href="/assets/js/71.ea0a8c5d.js"><link rel="prefetch" href="/assets/js/72.15382c9e.js"><link rel="prefetch" href="/assets/js/73.848364d3.js"><link rel="prefetch" href="/assets/js/74.5fd08a50.js"><link rel="prefetch" href="/assets/js/75.c937c70d.js"><link rel="prefetch" href="/assets/js/76.a0dacd5a.js"><link rel="prefetch" href="/assets/js/77.4019cc23.js"><link rel="prefetch" href="/assets/js/78.9676a9e1.js"><link rel="prefetch" href="/assets/js/79.e46e10d5.js"><link rel="prefetch" href="/assets/js/8.2098eb96.js"><link rel="prefetch" href="/assets/js/80.987e83cb.js"><link rel="prefetch" href="/assets/js/81.eb98ff36.js"><link rel="prefetch" href="/assets/js/82.623561a7.js"><link rel="prefetch" href="/assets/js/83.e256d909.js"><link rel="prefetch" href="/assets/js/84.7d06a550.js"><link rel="prefetch" href="/assets/js/85.b8d9879e.js"><link rel="prefetch" href="/assets/js/86.31c4581b.js"><link rel="prefetch" href="/assets/js/87.e06ee05e.js"><link rel="prefetch" href="/assets/js/88.81ef718d.js"><link rel="prefetch" href="/assets/js/89.ba237d2f.js"><link rel="prefetch" href="/assets/js/9.36092fd0.js"><link rel="prefetch" href="/assets/js/90.ad2c9d92.js"><link rel="prefetch" href="/assets/js/91.a661f52d.js"><link rel="prefetch" href="/assets/js/92.1c28035b.js"><link rel="prefetch" href="/assets/js/93.c8b8e3d6.js"><link rel="prefetch" href="/assets/js/94.b6bc4a44.js"><link rel="prefetch" href="/assets/js/95.92cea882.js"><link rel="prefetch" href="/assets/js/96.5373491b.js"><link rel="prefetch" href="/assets/js/97.bb39efc8.js"><link rel="prefetch" href="/assets/js/98.af7a030f.js"><link rel="prefetch" href="/assets/js/99.07dc87d8.js">
    <link rel="stylesheet" href="/assets/css/0.styles.d9c8cf8c.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="https://lingxin-tanhua.oss-cn-shanghai.aliyuncs.com/QQ%E6%88%AA%E5%9B%BE20220503092755.png" alt="凌歆的博客" class="logo"> <span class="site-name can-hide">凌歆的博客</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端" class="dropdown-title"><a href="/web/" class="link-title">前端</a> <span class="title" style="display:none;">前端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>学习笔记</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/note/html/" class="nav-link">HTML笔记</a></li><li class="dropdown-subitem"><a href="/note/js-low/" class="nav-link">JavaScript基础笔记</a></li><li class="dropdown-subitem"><a href="/note/js-high/" class="nav-link">JavaScript高阶笔记</a></li><li class="dropdown-subitem"><a href="/note/js-dom-bom/" class="nav-link">JavaScript DOM和BOM笔记</a></li><li class="dropdown-subitem"><a href="/note/jquery/" class="nav-link">jQuery笔记</a></li><li class="dropdown-subitem"><a href="/note/ajax/" class="nav-link">Ajax笔记</a></li><li class="dropdown-subitem"><a href="/note/nodejs/" class="nav-link">NodeJs笔记</a></li><li class="dropdown-subitem"><a href="/note/reg/" class="nav-link">正则表达式笔记</a></li><li class="dropdown-subitem"><a href="/note/vue/" class="nav-link">Vue笔记</a></li><li class="dropdown-subitem"><a href="/note/react/" class="nav-link">react笔记</a></li><li class="dropdown-subitem"><a href="/note/wx/" class="nav-link">微信小程序笔记</a></li><li class="dropdown-subitem"><a href="/note/uniapp/" class="nav-link">uniapp笔记</a></li><li class="dropdown-subitem"><a href="/note/echarts/" class="nav-link">echarts笔记</a></li><li class="dropdown-subitem"><a href="/note/git/" class="nav-link">Git笔记</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/back/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/java/" class="nav-link">JAVA</a></li><li class="dropdown-item"><!----> <a href="/note/javaweb/" class="nav-link">JavaWeb</a></li><li class="dropdown-item"><!----> <a href="/note/mysql/" class="nav-link">MySql</a></li><li class="dropdown-item"><!----> <a href="/note/ssm/" class="nav-link">ssm</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="算法" class="dropdown-title"><a href="/algor/" class="link-title">算法</a> <span class="title" style="display:none;">算法</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/sf/" class="nav-link">算法训练营</a></li><li class="dropdown-item"><!----> <a href="/note/js-sf/" class="nav-link">js数据结构与算法</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="面试" class="dropdown-title"><a href="/mianshi/" class="link-title">面试</a> <span class="title" style="display:none;">面试</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/lqb/" class="nav-link">蓝桥杯备战</a></li><li class="dropdown-item"><!----> <a href="/note/ms/" class="nav-link">前端面试</a></li><li class="dropdown-item"><!----> <a href="/note/hmms/" class="nav-link">黑马面试</a></li><li class="dropdown-item"><!----> <a href="/note/xzms/" class="nav-link">校招零距离面试</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="解决方案" class="dropdown-title"><a href="/resolve/" class="link-title">解决方案</a> <span class="title" style="display:none;">解决方案</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/qd-resolve/" class="nav-link">前端解决方案</a></li><li class="dropdown-item"><!----> <a href="/note/hd-resolve/" class="nav-link">后端解决方案</a></li></ul></div></div><div class="nav-item"><a href="/pages/beb6c0bd8a66cea6/" class="nav-link">收藏</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link">归档</a></li></ul></div></div> <a href="https://github.com/linxin1123/vuepress-blog" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><div class="blogger"><img src="https://lingxin-tanhua.oss-cn-shanghai.aliyuncs.com/QQ%E6%88%AA%E5%9B%BE20220503092755.png"> <div class="blogger-info"><h3>lingxin</h3> <span>凌歆</span></div></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端" class="dropdown-title"><a href="/web/" class="link-title">前端</a> <span class="title" style="display:none;">前端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>学习笔记</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/note/html/" class="nav-link">HTML笔记</a></li><li class="dropdown-subitem"><a href="/note/js-low/" class="nav-link">JavaScript基础笔记</a></li><li class="dropdown-subitem"><a href="/note/js-high/" class="nav-link">JavaScript高阶笔记</a></li><li class="dropdown-subitem"><a href="/note/js-dom-bom/" class="nav-link">JavaScript DOM和BOM笔记</a></li><li class="dropdown-subitem"><a href="/note/jquery/" class="nav-link">jQuery笔记</a></li><li class="dropdown-subitem"><a href="/note/ajax/" class="nav-link">Ajax笔记</a></li><li class="dropdown-subitem"><a href="/note/nodejs/" class="nav-link">NodeJs笔记</a></li><li class="dropdown-subitem"><a href="/note/reg/" class="nav-link">正则表达式笔记</a></li><li class="dropdown-subitem"><a href="/note/vue/" class="nav-link">Vue笔记</a></li><li class="dropdown-subitem"><a href="/note/react/" class="nav-link">react笔记</a></li><li class="dropdown-subitem"><a href="/note/wx/" class="nav-link">微信小程序笔记</a></li><li class="dropdown-subitem"><a href="/note/uniapp/" class="nav-link">uniapp笔记</a></li><li class="dropdown-subitem"><a href="/note/echarts/" class="nav-link">echarts笔记</a></li><li class="dropdown-subitem"><a href="/note/git/" class="nav-link">Git笔记</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/back/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/java/" class="nav-link">JAVA</a></li><li class="dropdown-item"><!----> <a href="/note/javaweb/" class="nav-link">JavaWeb</a></li><li class="dropdown-item"><!----> <a href="/note/mysql/" class="nav-link">MySql</a></li><li class="dropdown-item"><!----> <a href="/note/ssm/" class="nav-link">ssm</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="算法" class="dropdown-title"><a href="/algor/" class="link-title">算法</a> <span class="title" style="display:none;">算法</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/sf/" class="nav-link">算法训练营</a></li><li class="dropdown-item"><!----> <a href="/note/js-sf/" class="nav-link">js数据结构与算法</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="面试" class="dropdown-title"><a href="/mianshi/" class="link-title">面试</a> <span class="title" style="display:none;">面试</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/lqb/" class="nav-link">蓝桥杯备战</a></li><li class="dropdown-item"><!----> <a href="/note/ms/" class="nav-link">前端面试</a></li><li class="dropdown-item"><!----> <a href="/note/hmms/" class="nav-link">黑马面试</a></li><li class="dropdown-item"><!----> <a href="/note/xzms/" class="nav-link">校招零距离面试</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="解决方案" class="dropdown-title"><a href="/resolve/" class="link-title">解决方案</a> <span class="title" style="display:none;">解决方案</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/qd-resolve/" class="nav-link">前端解决方案</a></li><li class="dropdown-item"><!----> <a href="/note/hd-resolve/" class="nav-link">后端解决方案</a></li></ul></div></div><div class="nav-item"><a href="/pages/beb6c0bd8a66cea6/" class="nav-link">收藏</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link">归档</a></li></ul></div></div> <a href="https://github.com/linxin1123/vuepress-blog" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>学习笔记</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>蓝桥杯备战</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>前端面试</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading open"><span>基础篇</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/54f5cc/" aria-current="page" class="active sidebar-link">HTML篇(一)-cnblog</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/pages/54f5cc/#html篇-一" class="sidebar-link">HTML篇(一)</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/54f5cc/#一-题目目录" class="sidebar-link">一.题目目录</a></li><li class="sidebar-sub-header level4"><a href="/pages/54f5cc/#基础版本" class="sidebar-link">基础版本</a></li><li class="sidebar-sub-header level4"><a href="/pages/54f5cc/#详细版本" class="sidebar-link">详细版本</a></li><li class="sidebar-sub-header level4"><a href="/pages/54f5cc/#详细简版" class="sidebar-link">详细简版</a></li></ul></li></ul></li><li><a href="/pages/77c7be/" class="sidebar-link">HTML篇(二)-cnblog</a></li><li><a href="/pages/2f26cc/" class="sidebar-link">CSS篇(一)-cnblog</a></li><li><a href="/pages/693182/" class="sidebar-link">CSS篇(二)-cnblog</a></li><li><a href="/pages/a3a48c/" class="sidebar-link">JavaScript(一)</a></li><li><a href="/pages/d9b4e7/" class="sidebar-link">Javascript(二)-cnblog</a></li><li><a href="/pages/552413/" class="sidebar-link">JavaScript(三)</a></li><li><a href="/pages/b79209/" class="sidebar-link">JavaScript(四)</a></li><li><a href="/pages/97a8a1/" class="sidebar-link">JavaScript(五)</a></li><li><a href="/pages/50d3e4/" class="sidebar-link">JavaScript(六)</a></li></ul></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>进阶篇</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>高级篇</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>计算机基础</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>高频考点</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>精简版</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>综合问题版</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>复习篇</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>面试题集合</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>前端大厂面试宝典</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>前端基础题汇总</span> <span class="arrow right"></span></p> <!----></section></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>黑马面试</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>校招零距离面试</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><a href="/mianshi/#面试" data-v-06225672>面试</a></li><li data-v-06225672><a href="/mianshi/#前端面试" data-v-06225672>前端面试</a></li><li data-v-06225672><a href="/mianshi/#基础篇" data-v-06225672>基础篇</a></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="https://github.com/linxin1123" target="_blank" title="作者" class="beLink" data-v-06225672>lingxin</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2023-02-26</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">HTML篇(一)-cnblog<!----></h1>  <div class="theme-vdoing-content content__default"><h2 id="html篇-一"><a href="#html篇-一" class="header-anchor">#</a> HTML篇(一)</h2> <h3 id="一-题目目录"><a href="#一-题目目录" class="header-anchor">#</a> 一.题目目录</h3> <ol><li><a href="#q1">前端需要注意哪些SEO</a></li> <li><a href="#q2"><code>&lt;img&gt;</code>的title和alt的区别</a></li> <li><a href="#q3">HTTP的几种请求方法用途</a></li> <li><a href="#q4">从浏览器地址栏输入url到显示页面的步骤</a></li> <li><a href="#q5">如何进行网站性能优化</a></li> <li><a href="#q6">HTTP状态码及其含义</a></li> <li><a href="#q7">语义化的理解</a></li> <li><a href="#q8">对浏览器内核的理解</a></li> <li><a href="#q9">html5的新特性、移除了哪些元素</a></li> <li><a href="#q10">HTML5的离线存储怎么使用，解释一下工作原理</a></li> <li><a href="#q11">HTML5是怎么对HTML5的离线存储资源进行管理和加载的呢</a></li> <li><a href="#q12">请描述一下cookies，sessionStorage和localStorage的区别</a></li> <li><a href="#q13">iframe有哪些缺点</a></li> <li><a href="#q14">WEB标准以及W3C标准是什么</a></li> <li><a href="#q15">xhtml和html的区别</a></li> <li><a href="#q16">Doctype作用？严格模式与混杂模式如何区分？它们有何意义</a></li> <li><a href="#q17">行内元素有哪些，块级元素有哪些，空(void)元素有哪些？行内元素和块级元素的区别</a></li> <li><a href="#q18">HTML全局属性(global attribute)有哪些</a></li> <li><a href="#q19">Canvas和SVG有什么区别？</a></li> <li><a href="#q20">HTML5为什么只需要写!DOCTYPE HTML</a></li></ol> <h3 id="q1">1. 前端需要注意哪些SEO</h3> <ul><li>合理的<strong>title、description、keywords</strong>：搜索对着三项的权重逐个减小
<ul><li><strong>title</strong>值强调重点、重要关键词不要出现2次</li> <li>不同页面<strong>title</strong>值不同</li> <li><strong>description</strong>将页面内容高度囊括，长度合适，不过分堆凑关键词</li> <li>不同页面<strong>description</strong>不同</li></ul></li> <li>语义化<strong>HTML</strong>代码，符合W3C规范：语义化代码让搜索引擎更容易理解网页</li> <li>重要内容的<strong>HTML</strong>代码放在最前面</li> <li>重要内容不要用<strong>js</strong>输出，爬虫不会执行js获取内容</li> <li>少用<strong>iframe</strong>，搜索引擎不会抓取iframe的内容</li> <li>非装饰性图片必须加alt</li> <li>提高网站速度：网站速度是搜索引擎排序的一个重要指标</li></ul> <h3 id="q2">2. img 的title和alt的区别</h3> <ul><li>title是鼠标滑动到元素上时显示</li> <li>alt是img的属性，用于图片无法加载时显示的描述文字，属性存在可以提高可访问性</li></ul> <h3 id="q3">3. HTTP的几种请求方法用途</h3> <ul><li>GET请求
<ul><li>发送一个请求取得服务器上的某一资源</li></ul></li> <li>POST请求
<ul><li>向URL指定的资源提交数据或者附加新的数据</li></ul></li> <li>PUT请求
<ul><li>和POST请求很像，也是向服务器提交数据，但是PUT指定了资源在服务器的位置，而POST没有</li></ul></li> <li>HEAD请求
<ul><li>只请求页面的首部</li></ul></li> <li>DELETE请求
<ul><li>删除服务器上某资源</li></ul></li> <li>OPTIONS请求
<ul><li>预检请求，获取当前URL所支持的方法，如果请求成功，会有一个Allow的头包含类似“GET，POST”这样的信息</li></ul></li> <li>TRACE请求
<ul><li>用于激发一个远程的，应用层的请求消息回路</li></ul></li> <li>CONNECT请求
<ul><li>把请求连接转换到透明的TCP/IP通道</li></ul></li></ul> <h3 id="q4">4. 从浏览器地址栏输入url到显示页面的步骤</h3> <h4 id="基础版本"><a href="#基础版本" class="header-anchor">#</a> 基础版本</h4> <ol><li>浏览器根据请求的URL进行DNS域名解析，找到真实IP，向服务器发起请求</li> <li>服务器交给后台处理完成后返回数据，浏览器接受文件(HTML,JS,CSS,图像等)</li> <li>浏览器对加载到的资源（HTML，js,css）进行语法解析，建立相应的内部数据结构</li> <li>载入解析到的资源文件，渲染页面，完成</li></ol> <h4 id="详细版本"><a href="#详细版本" class="header-anchor">#</a> 详细版本</h4> <ol><li><p>浏览器地址栏输入URL</p></li> <li><p>浏览器查看缓存，如果请求资源在缓存且为过期，跳转到转码步骤</p> <ol><li>如果资源未缓存，发起新的请求</li> <li>如果已经缓存未过期，直接提供给客户端</li> <li>HTTP头</li></ol> <div class="language- extra-class"><pre><code>- Expires和Cache-Control
- HTTP1.0 Expries，值未过期时间
- HTTP1.1 Cache-Control:max-age=，值为秒为单位的最大新鲜时间
</code></pre></div></li> <li><p>浏览器解析URL获取协议，主机，端口，path</p></li> <li><p>组装HTTP请求报文</p></li> <li><p>浏览器获取主机IP地址</p> <ol><li>浏览器缓存</li> <li>本地缓存</li> <li>hosts文件</li> <li>路由器缓存</li> <li>ISP DNS缓存</li> <li>DNS递归查询</li></ol></li> <li><p>打开一个socket与目标IP地址，端口建立TCP连接，三次握手</p> <ol><li>客户端发送TCP的SYN=1，Seq=X的包给服务器</li> <li>服务端返回SYN=1，ACK=X+1，Seq=Y的响应包</li> <li>客户端发送ACK=Y+1，Seq=Z</li></ol></li> <li><p>TCP连接建立后发送HTTP请求</p></li> <li><p>服务器接受请求并解析，请求转发到服务程序</p></li> <li><p>服务器检查HTTP请求头是否包含缓存验证消息，如果存在缓存，返回304等状态码</p></li> <li><p>处理程序读取完整请求并准备HTTP响应，可能需要查询数据库</p></li> <li><p>服务器将响应报文通过TCP连接发送回浏览器</p></li> <li><p>浏览器接收HTTP响应，然后根据情况选择关闭TCP连接或者保留重用，关闭TCP连接的四次握手如下</p> <ol><li>主动方发送Fin=1，ACK=Z，Seq=X报文</li> <li>被动方发送ACK=X+1，Seq=Z报文</li> <li>被动方发送Fin=1，ACK=X，Seq=Y报文</li> <li>主动发发送ACK=Y，Seq=X报文</li></ol></li> <li><p>浏览器检查响应状态码：是否为1XX，3XX，4XX，5XX，这些情况处理与2XX不同</p></li> <li><p>如果资源可以缓存，进行缓存</p></li> <li><p>对响应进行解码</p></li> <li><p>根据资源类型决定如何处理(假设资源为HTML文档)</p></li> <li><p>解析HTML文档，构建DOM树，下载资源，构造CSSOM树，执行js脚本，这些操作没有严格的先后顺序</p></li> <li><p>构建DOM树</p> <ol><li>Tokenizing:根据HTML规范将字符流解析为标记</li> <li>Lexing：词法分析将标记转换为对象并定义属性和规则</li> <li>DOM construction：根据HTML标记关系组成DOM树</li></ol></li> <li><p>解析过程遇到图片、样式表、js文件，自动下载</p></li> <li><p>构建CSSOM树</p> <ol><li>Tokenizing：字符流转换为标记流</li> <li>Node：根据标记创建节点</li> <li>CSSOM：节点创建CSSOM树</li></ol></li> <li><p>根据DOM树和CSSOM树构建渲染树</p> <ol><li>从DOM树的根节点遍历所有可见节点，不可见节点包括
<ul><li>script，meta这样本身不可见的标签</li> <li>被css隐藏的节点：display：none</li></ul></li> <li>对每一个可视节点，找到恰当的CSSOM规则并应用</li> <li>发布可视节点的内容和计算样式</li></ol></li> <li><p>js解析如下</p> <ol><li>浏览器创建Document对象并解析HTML，将解析的元素和文本节点添加到文档中，此时document.readystate为loading</li> <li>HTML解析器遇到没有async和defer的script，将他们添加到文档中，然后执行行内或外部脚本。这些脚本会同步执行，并且在脚本下载和执行时解析器会暂停。这样就可以用document,write()将文本插入到输入流中。同步脚本经常简单定义函数和注册事件处理程序，他们可以遍历和操作script和他们之前的文档内容</li> <li>当解析器遇到设置了async属性的script时，开始下载脚本并继续解析文档。脚本会在它下载完成后尽快执行，但是解析器不会停下来等他下载。异步脚本禁止使用document,write(),他们可以访问自己script和之前的文档元素</li> <li>当文档完成解析，document.readState变成interactive</li> <li>所有defer脚本按照在文档出现的顺序执行，延迟脚本能访问完整文档树，禁止使用document.write()</li> <li>浏览器在Document对象上触发DOMContentLoaded事件’</li> <li>此时文档完全解析，浏览器可能还在等待图片等内容加载，等这些内容载入并且所有异步脚本完成载入和执行，document.readState变为complete，window触发load事件</li></ol></li> <li><p>显示页面</p></li></ol> <h4 id="详细简版"><a href="#详细简版" class="header-anchor">#</a> 详细简版</h4> <ol><li><p>从浏览器接收url到开启网络请求线程(这一部分可以展开浏览器的机制以及进程与线程的关系)</p></li> <li><p>开启网络线程到发出一个完整的HTTP请求(这一部分涉及dns查询，TCP/IP请求，协议栈)</p></li> <li><p>从服务器接收到请求到对应后台接收到请求（这一部分涉及负载均衡，安全拦截以及后台内部的处理等等）</p></li> <li><p>后台与前台的HTTP交互（这一部分包括HTTP头部、响应码、报文结构、cookie等知识，可以提下静态资源的cookie优化，编码解码）</p></li> <li><p>缓存问题，HTTP缓存（ETag,catch-control）</p></li> <li><p>浏览器接收到HTTP数据包的解析流程</p></li> <li><p>CSS的可视化格式模型（元素的渲染规则，如包含块、控制框，BFC，IFC）</p></li> <li><p>JS引擎解析过程</p></li> <li><p>其他</p></li></ol> <h3 id="q5">5. 如何进行网站性能优化</h3> <ul><li>content方面
<ul><li>减少HTTP请求、css精灵图、inline Image</li> <li>减少DNS查询：DNS缓存，资源分布到恰当数量的主机名</li> <li>减少Dom元素数量</li></ul></li> <li>Server方面
<ul><li>使用CDN</li> <li>配置ETag</li> <li>对组件进行Gzip压缩</li></ul></li> <li>Cookie方面
<ul><li>减少cookie大小</li></ul></li> <li>css方面
<ul><li>将样式表放在页面顶部</li> <li>不使用css表达式</li> <li>使用<link>不使用@import</li></ul></li> <li>Javascript方面
<ul><li>将脚本放在页面底部</li> <li>将javascript和css从外部引入</li> <li>删除不需要的脚本</li> <li>减少dom访问</li></ul></li> <li>图片方面
<ul><li>优化图片：根据实际颜色需要选择色深、压缩</li> <li>优化css精灵</li> <li>不要在HTML中拉伸图片</li></ul></li></ul> <h3 id="q6">6. HTTP状态码及其含义</h3> <ul><li>1XX:信息状态码
<ul><li>100 Continue 继续，一般在发送post请求时，已发送http header之后服务端将返回此信息，表示确认，之后发送具体参数信息</li></ul></li> <li>2XX：成功状态码
<ul><li>200 OK 正常返回信息</li> <li>201 Created 请求成功并且服务器创建了新的资源</li> <li>202 Accepted 服务器已接受请求，但尚未处理</li></ul></li> <li>3XX：重定向
<ul><li>301 Moved Permanently 请求的网页已永久移动到新位置</li> <li>302 Found 临时性重定向</li> <li>303 See Other 临时性重定向，且总是使用GET请求新的URI</li> <li>304 Not Modified 自从上次请求后，请求的网页未修改过</li></ul></li> <li>4XX：客户端错误
<ul><li>400 Bad Request 服务器无法理解请求的格式，客户端不应当尝试再次使用相同的内容发起请求</li> <li>401 Unauthorization 请求未授权</li> <li>403 禁止访问</li> <li>404 Not Found 找不到如何与URI相匹配的资源</li></ul></li> <li>5XX：服务器错误
<ul><li>500 Internal Server Error ：最常见的服务端错误</li> <li>503 Service Unavailable：服务器端暂时无法处理请求</li></ul></li></ul> <h3 id="q7">7. 语义化的理解</h3> <ul><li>用正确的标签做正确的事</li> <li>HTML语义化就是让页面的内容结构化，便于浏览器、搜索引擎解析</li> <li>在没有样式CSS情况下也以一种文档格式显示，并且是容易阅读的</li> <li>搜索引擎的爬虫依赖于标记来确定上下文和各个关键字的权重，利于SEO</li> <li>使阅读源代码的人对网站更容易将网站分块，便于阅读维护理解</li></ul> <h3 id="q8">8. 介绍一下你对浏览器内核的理解</h3> <ul><li>主要分成两部分：渲染引擎(layout engineer 或者 Rendering Engine) 和 JS引擎</li> <li>渲染引擎：负责取得网页的内容（HTML 、XML、图像等等)、整理讯息（例如加入css等），以及计算网页的显示方式，然后会输出至显示器或打印机。浏览器的内核的不同对于网页的语法解释会有不同，所以渲染的效果也不相同。所有网页浏览器。电子邮件客户端以及其他需要编辑。显示网络内容的应用程序也都需要内核</li> <li>JS引擎：解析和执行JavaScript来实现网页的动态效果</li> <li>最开始渲染引擎和js引擎没有区分的很明确，后来js引擎越来越独立，内核就倾向于指渲染引擎</li></ul> <h3 id="q9">9. html5的新特性、移除了哪些元素</h3> <ul><li><p>主要是关于图像，位置，存储，多功能等功能的增加</p> <ul><li>绘画canvas</li> <li>媒体 video和audio元素</li> <li>本地离线存储localstorage，浏览器关闭数据不丢失</li> <li>sessionstorage，浏览器关闭自动删除</li> <li>语义化标签，article，footer，header，nav，section</li> <li>表单控件，calendar，date，time，email，url，search</li> <li>新的技术 webworker，websocket，Geolocation</li></ul></li> <li><p>移除的元素</p> <ul><li>纯表现的元素：basefont、big、center、font、s、strike、tt、u</li> <li>对可用性产生负面影响的元素：frame、frameset、noframes</li></ul></li> <li><p>支持HTML5新标签</p> <ul><li>IE8/IE7/IE6支持document.createElement方法产生的标签</li> <li>可以利用这一特性让浏览器支持HTML5新标签</li> <li>浏览器支持新标签后，还需要添加标签默认的样式</li></ul></li></ul> <h3 id="q10">10. html5的离线存储怎么使用，工作原理能不能解释一下？</h3> <ul><li>在用户没有与因特网连接时，可以正常访问站点或应用，在用户与因特网连接时，更新机器上的缓存文件</li> <li>原理：HTML5的离线存储是基于一个新建.appcache文件的缓存机制（不是存储技术）</li> <li>通过这个文件上的解析清单离线存储资源，这些资源就会像cookie一样被存储下来，之后当网络在处于离线状态下时，浏览器会通过被离线存储的数据进行页面展示</li> <li>如何使用
<ul><li>页面头部加入下面一个manifest的属性</li> <li>在cache.manifest 文件的编写离线存储的资源</li> <li>在离线状态时，操作window.applicationCache进行需求实现</li></ul></li></ul> <div class="language-code line-numbers-mode"><pre class="language-text"><code>CACHE MANIFEST
#v0.11
CACHE
js/app.js
css/style.css
NETWORK:
resource/logo.png
FALLBACK:
/offline.html

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><h3 id="q11">11. 浏览器是怎么对 HTML5 的离线储存资源进⾏管理和加载的呢
</h3>
- 在线的情况下，浏览器发现html头部有manifest属性，他会请求manifest文件，如果是第一次访问app，那么浏览器就会根据manifest文件的内容下载相应的资源并且进行离线存储。如果已经访问过app并且资源已经离线存储了，那么浏览器就会使用离线的资源加载页面，然后浏览器会比对新的manifest文件与旧的manifest文件，如果文件没有发生改变，就不做任何操作，如果文件改变了，那么就会重新下载文件中的资源并进行离线存储
<ul><li>离线的情况下，浏览器就直接使用离线存储的资源</li></ul> <h3 id="q12">12. 请描述⼀下 cookies ， sessionStorage 和 localStorage 的区别？
</h3>
- cookie是网站为了标示用户身份而存储在用户本地终端(Client Side)上的数据(通常经过加密)
- cookie数据始终在同源的http请求中携带(即使不需要),即会在浏览器和服务器间来回传递
- sessionStorage和localStorage不会自动把数据发给服务器，仅在本地保存
- 存储大小
  - cookie数据大小不能超过4k
  - sessionStorage和localStorage虽然也有存储大小的限制，但比cookie大得多，可以达到5M或更大
- 过期时间
  - localStorage存储持久数据,浏览器关闭后数据不丢失除非主动删除数据
  - sessionStorage数据在当前浏览器窗口关闭后自动删除
  - cookie设置的cookie过期时间之前一直有效，即使窗口或浏览器关闭
<h3 id="q13">13. iframe有那些缺点？
</h3>
- iframe会阻塞主页面的onLoad事件
- 搜索引擎的检索查询无法解读这种页面，不利于SEO
- iframe和主页面共享连接池，而浏览器对相同域的连接有限制，所以会影响页面的并行加载
- 如果需要使用iframe，最好通过JavaScript添加src属性
<h3 id="q14">14. WEB标准以及W3C标准是什么?
</h3>
- 标签闭合、标签小写。不乱嵌套、使用外链css和js、结构行为表现的分离
<h3 id="q15">15. xhtml和html有什么区别?
</h3>
- 一个是功能上的差别
  - 主要是XHTML可兼容各大浏览器、手机以及PDA，并且浏览器也能快速正确地编译网页
- 另外是书写习惯的差别
  - XHTML元素必须被正确的嵌套，闭合，区分大小写，文档必须拥有根元素
<h3 id="q16">16. Doctype作⽤? 严格模式与混杂模式如何区分？它们有何意义?
</h3> <ul><li>页面被加载时，link会同时被加载，而@import页面被加载时，link会同时被加载，而@import引用的css会等到页面加载完成再加载，import只要IE5以上才能识别，而link为XHTML标签，无兼容性问题，link方式的样式的权重高于@import的权重</li> <li><code>&lt;!DOCTYPE&gt;</code>声明位于文档中的最前面，处于<code>&lt;html&gt;</code>标签之前。告知浏览器的解析器，用什么文档类型规范来解析这个文档</li> <li>严格模式的排版和JS运作模式是以该浏览器支持的最高标准运行</li> <li>再混杂模式中，页面以宽松的向后兼容的方式显示。模拟老式浏览器的行为以防止站点无法工作。<code>DOCTYPE</code>不存在或格式不正确会导致文档已混杂模式呈现</li></ul> <h3 id="q17">17. ⾏内元素有哪些？块级元素有哪些？ 空(void)元素有那些？⾏内元
素和块级元素有什么区别？
</h3>
- 行内元素： a,b,span,img,input,select,strong
- 块级元素：div ul ol li dl dt dd h1 h2 h3 p
- 空元素： br,hr,img,input,link,meta
- 行内元素不可以设置宽高，不独占一行
- 块级元素可以设置宽高，独占一行
<h3 id="q18">18. HTML全局属性(global attribute)有哪些
</h3>
- class：为元素设置类标识
- data-*：为元素增加自定义属性
- draggable：设置元素是否可拖拽
- id：元素id，文档内唯一
- lang：元素内容的语言
- style：行内css样式
- title：元素相关的建议信息
<h3 id="q19">19. Canvas 和 SVG有什么区别
</h3> <ul><li>svg绘制出来的每一个图形的元素都是独立的DOM节点，能够方便的绑定事件或用来修改。canvas输出的是一整幅画布</li> <li>svg输出的图像是矢量图形，后期可以修改参数来自由放大缩小，不会失真和锯齿。而canvas输出标量画布，就行一张图片一样，放大会失真</li></ul> <h3 id="q20">20. HTML5为什么只需要写!DOCTYPE HTML
</h3>
- HTML5 不基于SGML，因此不需要对DTD进行引用，但是需要doctype来规范浏览器的行为
- 而HTML4.01基于SGML，所以需要对DTD进行引用，才能告知浏览器文档所使用的文档类型</div></div>  <div class="page-edit"><div class="edit-link"><a href="https://github.com/linxin1123/vuepress-blog/edit/master/docs/08.面试/02.前端面试/01.基础篇/01.HTML篇(一)-cnblog.md" target="_blank" rel="noopener noreferrer">编辑</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2023/02/26, 19:02:51</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/pages/731437/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">NodeJs复习-cnblog</div></a> <a href="/pages/77c7be/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">HTML篇(二)-cnblog</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/pages/731437/" class="prev">NodeJs复习-cnblog</a></span> <span class="next"><a href="/pages/77c7be/">HTML篇(二)-cnblog</a>→
      </span></p></div></div></div> <div class="article-list"><div class="article-title"><a href="/archives/" class="iconfont icon-bi">最近更新</a></div> <div class="article-wrapper"><dl><dd>01</dd> <dt><a href="/pages/0b785d/"><div>
            Vuex
            <!----></div></a> <span class="date">03-14</span></dt></dl><dl><dd>02</dd> <dt><a href="/pages/c59cc0/"><div>
            Vue响应式原理
            <!----></div></a> <span class="date">03-14</span></dt></dl><dl><dd>03</dd> <dt><a href="/pages/83cc7a/"><div>
            Vue虚拟DOM-cnblog
            <!----></div></a> <span class="date">03-14</span></dt></dl> <dl><dd></dd> <dt><a href="/archives/" class="more">更多文章&gt;</a></dt></dl></div></div></main></div> <div class="footer"><div class="icons"><a href="3010733382@qq.com" title="发邮件" target="_blank" class="iconfont icon-youjian"></a><a href="https://github.com/linxin1123" title="GitHub" target="_blank" class="iconfont icon-github"></a><a href="https://music.163.com/#/playlist?id=755597173" title="听音乐" target="_blank" class="iconfont icon-erji"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2022-2023
    <span>lingxin | <a href="https://github.com/linxin1123/vuepress-blog/blob/master/LICENSE" target="_blank">MIT License</a></span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"><div></div></div></div>
    <script src="/assets/js/app.57550e13.js" defer></script><script src="/assets/js/2.f014c35f.js" defer></script><script src="/assets/js/128.0edf0e06.js" defer></script>
  </body>
</html>
